<template>
	<div id="kcbox">
		<div
			style="width: 80mm;font-size: 12px;
		    padding: 10px;
		    border: 1px solid #a5a5a5;
		    box-shadow: 2px 2px 2px #d3d3d3;text-align: left;"
		>
			<h2>{{ sellerInfo.name }}({{ orderInfo.eatType }})</h2>
			<p>
				<span v-show="false" id="eatType">{{ orderInfo.eatType }}</span>
				<span>联系人:{{ orderInfo.linkMan }}</span>
				<br />
				<span>联系电话:{{ orderInfo.linkTel }}</span>
				<br />
				<span>地址:{{ orderInfo.address }}</span>
				<br />
				<span>份数:{{ orderInfo.number }}</span>
				<br />
				<span>配送员:{{ orderInfo.staffName }}</span>
				<br />
			</p>
			<div>------------------------------------------------------</div>
			<el-table :data="orderInfo.foodVos" style="width: 100%;">
				<el-table-column prop="foodName" label="品名">
					<template slot-scope="scope">
						<div>
							<span v-show="scope.row.giveFoodStatus === 1" style="color: red;">赠</span>
							{{ scope.row.foodName }}
						</div>
					</template>
				</el-table-column>
				<el-table-column prop="foodNum" label="数量">
					<template slot-scope="scope">
						<i class="el-icon-remove-outline cursor" @click="removeFood(scope.row)"></i>
						&nbsp;&nbsp;{{ scope.row.foodNum }}&nbsp;&nbsp;
						<i class="el-icon-circle-plus-outline cursor" @click="addFood(scope.row)"></i>
					</template>
				</el-table-column>
				<el-table-column label="金额">
					<template slot-scope="scope">
						<div style="color: red;">￥{{ Number(scope.row.total) }}元</div>
					</template>
				</el-table-column>
			</el-table>
			<br />
			<div>------------------------------------------------------</div>
			<div>
				合计:
				<span style="color: red;size: 1.25rem;">￥{{ orderInfo.totalMoney }}元</span>
				<br />
				应收:
				<span style="color: red;size: 1.25rem;">￥{{ orderInfo.totalMoney }}元</span>
				<br />
				实收:
				<span style="color: red;size: 1.25rem;">￥{{ orderInfo.reallyGet }}元</span>
				<br />
			</div>
			<div>------------------------------------------------------</div>
			<div style="margin-top: 10px;"></div>
			<p id="accountBoxs" v-if="orderInfo.accountId !== null">
				挂账单位:{{ orderInfo.unitInfo.accountUnitName }}
				<br />
				总挂单数:{{ orderInfo.unitInfo.totalAccountNum }}
				<br />
				已清单数:{{ orderInfo.unitInfo.totalAccountNum }}
				<br />
				未结款金额:{{ orderInfo.unitInfo.notSettlementTotal }}
			</p>

			<div id="memberBoxs" v-if="orderInfo.memberId !== null">
				会员昵称:{{ orderInfo.memberInfos.memberNick }}
				<br />
				会员类型:{{ orderInfo.memberTypeName }}
				<br />
				会员卡号:{{ orderInfo.memberInfos.memberCardNo }}
				<br />
				会员名字:{{ orderInfo.memberInfos.memberName }}
				<br />
				电话号码:{{ orderInfo.memberInfos.tel }}
				<br />
				账户余额:{{ orderInfo.memberAccountInfo.balace }}
				<br />
				账户积分:{{ orderInfo.memberAccountInfo.integral }}
				<br />
				累计消费:{{ orderInfo.memberAccountInfo.totalConsume }}
			</div>

			<p>
				<span>联系电话:{{ sellerInfo.linkTel }}</span>
			</p>
			<p>
				<span>地址:{{ sellerInfo.address }}</span>
			</p>
			<div style="margin: 8px 0px;">操作员:{{ sellerInfo.linkName }}</div>

			<h1>谢谢光临</h1>
		</div>
	</div>
</template>

<script>
import { getLodop } from '../../../../../utils/lodop.js';
export default {
	data() {
		return {
			sellerInfo: {},
			orderInfo: {}
		};
	},

	created() {
		this.initData();
	},

	methods: {
		initData() {
			this.sellerInfo = JSON.parse(this.$cookie.get('sellerInfo'));
		},

		init(orderInfo) {
			console.log("ordd       "+JSON.stringify(orderInfo))
			this.orderInfo = orderInfo;
			if (document.getElementById('eatType') === null || document.getElementById('eatType').innerText !== this.orderInfo.eatType) {
				this.$emit('DataIsNull');
			} else {
				let LODOP = getLodop();
				if (LODOP != null && typeof LODOP.VERSION != 'undefined') {
					LODOP.PRINT_INIT('');
					LODOP.SET_PRINT_PAGESIZE(3, '58mm', '10mm', 'CreateCustomPage');
					LODOP.SET_PRINT_STYLE('FontSize', 15); // 设置打印字体
					LODOP.SET_PRINT_STYLE('Bold', 1); // 设置加粗
					LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Height:90%');
					LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Full-Width');
					var parent = document.getElementById('kcbox');
					//挂账单位模板
					if (orderInfo.accountId === null) {
						var child = document.getElementById('accountBoxs');
						if (child !== null) {
							parent.removeChild(child);
						}
					}
					//会员模板
					if (orderInfo.memberId === null) {
						var child = document.getElementById('memberBoxs');
						if (child !== null) {
							parent.removeChild(child);
						}
					}
					if (orderInfo.accountId === null && orderInfo.memberId === null) {
						var child1 = document.getElementById('accountBoxs');
						if (child1 !== null) {
							parent.removeChild(child1);
						}
						var child2 = document.getElementById('memberBoxs');
						if (child2 !== null) {
							parent.removeChild(child2);
						}
						var child3 = document.getElementById('lineBoxs');
						if (child3 !== null) {
							parent.removeChild(child3);
						}
					}
					LODOP.ADD_PRINT_HTM(10, 10, '100%', '70%', parent.innerHTML);
					LODOP.PRINT();
					//LODOP.PREVIEW();
				}
			}
		}
	}
};
</script>

<style></style>
